import { PanelLayoutData } from '../../example/panel-layout-data';
import { PanelDataProvider, PanelLayoutProvider } from '../../interface';

/**
 * 布局面板适配器
 *
 * @author chitanda
 * @date 2022-02-17 16:02:47
 * @export
 * @class LayoutPanelProvider
 * @implements {PanelLayoutProvider}
 */
export class LayoutPanelProvider implements PanelLayoutProvider {
  type = 'CONTAINER';

  layout: 'absolute' | 'gird' | 'table' = 'absolute';

  materialGroup = '';

  materialComponent = 'layout-panel-material';

  contentComponent = 'layout-panel';

  async createItem(parent: PanelDataProvider | null): Promise<PanelDataProvider> {
    console.log(parent, '新建布局容器');
    const data = new PanelLayoutData({
      psappportalviewname: 'AppPortalView',
      updateman: 'test_0805_001',
      pssystemid: '2C40DFCD-0DF5-47BF-91A5-C45F810B0001',
      createdate: '2022-02-17 14:40:01',
      colspan: 1,
      ordervalue: 100,
      createman: 'test_0805_001',
      updatedate: '2022-02-17 14:40:01',
      validflag: 1,
      psapppvpartname: 'container1-' + new Date().getTime(),
      psapppvpartid: new Date().getTime(),
      colid: 0,
      pvparttype: 'CONTAINER',
      psappportalviewid: '3DEFA381-5219-4670-9300-BB191266044D',
    });
    console.log(data, '新建布局容器');
    return data;
  }

  async moveItem(
    from: PanelDataProvider<unknown>,
    to: PanelDataProvider<unknown>,
    item: PanelDataProvider<unknown>,
  ): Promise<boolean> {
    console.log(from, to, item, '移动布局容器');
    return true;
  }

  removeItem(item: PanelDataProvider<unknown>): Promise<boolean> {
    throw new Error('Method not implemented.');
  }
}
